#

EXTRA_DIST = \
	gl.xml

lib_LTLIBRARIES = libwgl.la

libwgl_la_CPPFLAGS = \
	-I$(top_srcdir) \
	-I$(top_srcdir)/glm \
	-DWGL_COMPILE \
	@WGL_CFLAGS@ \
	@SDL_CFLAGS@

libwgl_la_LDFLAGS = \
	@WGL_LDFLAGS@ \
	-no-undefined

libwgl_la_LIBADD = \
	@SDL_LIBS@

libwgl_la_SOURCES = \
	wglstb.cpp \
	wgltinyobjloader.cpp \
	wgldebug.cpp \
	wglutils.cpp \
	wglquark.cpp \
	wglinstance.cpp \
	wglapplayer.cpp \
	wglapplayerdebug.cpp \
	wglwindow.cpp \
	wglcontext.cpp \
	wglfont.cpp \
	wgltexture.cpp \
	wglmesh.cpp \
	wglmeshbuffer.cpp \
	wglshader.cpp \
	wglprogram.cpp \
	wgltransfo.cpp \
	wglcamera.cpp \
	wgllight.cpp

WGLBUILTHDRS = \
	wgl_gltypes.inl.hpp \
	wgl_glenums.inl.hpp \
	wgl_glfuncs.inl.hpp \
	wglapplayer.inl.hpp \
	wglapplayerdebug.inl.hpp

WGLHDRS = \
	$(WGLBUILTHDRS) \
	wgl.hpp \
	wglbase.hpp \
	wgldebug.hpp \
	wglutils.hpp \
	wglquark.hpp \
	wglinstance.hpp \
	wgl_gl.hpp \
	wgl_gltypes.hpp \
	wgl_glenums.hpp \
	wgl_glfuncs.hpp \
	wglapplayer.hpp \
	wglapplayerdebug.hpp \
	wglwindow.hpp \
	wglcontext.hpp \
	wglfont.hpp \
	wgltexture.hpp \
	wglmesh.hpp \
	wglmeshbuffer.hpp \
	wglshader.hpp \
	wglprogram.hpp \
	wgltransfo.hpp \
	wglcamera.hpp \
	wgllight.hpp \
	wglmaterial.hpp

BUILT_SOURCES = \
	$(WGLBUILTHDRS) \
	wglapplayer.inl.cpp \
	wglapplayerdebug.inl.cpp

CLEANFILES = \
	$(WGLBUILTHDRS) \
	wglapplayer.inl.cpp \
	wglapplayerdebug.inl.cpp \
	wglapplayer.stamp-h \
	wglapplayerdebug.stamp-h

wgl_gltypes.inl.hpp \
wgl_glenums.inl.hpp \
wgl_glfuncs.inl.hpp \
wglapplayer.inl.hpp \
wglapplayer.inl.cpp \
: wglapplayer.stamp-h

wglapplayerdebug.inl.hpp wglapplayerdebug.inl.cpp: wglapplayerdebug.stamp-h

wglapplayer.stamp-h: gl.xml $(top_builddir)/wglmkapplayer/wglmkapplayer.stamp-h
	DEBUG='no' PYTHONPATH=$(abs_top_srcdir) $(PYTHON) -m wglmkapplayer -m -b wgl $<
	echo >$@

wglapplayerdebug.stamp-h: gl.xml $(top_builddir)/wglmkapplayer/wglmkapplayer.stamp-h
	DEBUG='no' PYTHONPATH=$(abs_top_srcdir) $(PYTHON) -m wglmkapplayer -l Debug -b wgl $<
	echo >$@

# headers install
if WGL_INSTALL_SYMLINK
INSTALL_HEADERS_SYMLINK = install-headers-symlink
pkginclude_HEADERS =
INSTALL_GLM = $(LN_S)
else !WGL_INSTALL_SYMLINK
INSTALL_HEADERS_SYMLINK =
pkginclude_HEADERS = $(WGLHDRS)
INSTALL_GLM = install
endif

.PHONY: install-headers-symlink uninstall-headers install-glm

install-data-hook: $(INSTALL_HEADERS_SYMLINK) install-glm

uninstall-hook: uninstall-headers

install-headers-symlink:
	rm -rf "$(DESTDIR)$(pkgincludedir)"
	test -d "$(DESTDIR)$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)"
	for hdr in $(WGLHDRS); do \
		src=`realpath "$${hdr}"`; \
		test -f "$${src}" || src="$(abs_top_srcdir)/wgl/$${hdr}"; \
		test -f "$${src}" || { echo "E: header not found: '$${src}'" >&2; exit 1; }; \
		dst="$(DESTDIR)$(pkgincludedir)/$${hdr}"; \
		$(LN_S) "$${src}" "$${dst}"; \
	done

install-glm:
	test -d "$(DESTDIR)$(glmincludedir)" || mkdir -vp "$(DESTDIR)$(glmincludedir)"
	for hdr in `cd $(top_srcdir)/glm && find -type f '(' -name 'copying.txt' -o -name '*.h' -o -name '*.hpp' -o -name '*.inl' ')'`; do \
		hdrdir="$(DESTDIR)$(glmincludedir)/`dirname $${hdr}`"; \
		test -d "$${hdrdir}" || mkdir -vp "$${hdrdir}"; \
		$(INSTALL_GLM) "$(top_srcdir)/glm/$${hdr}" "$${hdrdir}"; \
	done

uninstall-headers:
	rm -r $(DESTDIR)$(pkgincludedir)
